<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/">
    <xi:include href="master.html" />


<head />

<body>

<?python from mnemoply import model
         from mnemoply._renewed_model.field import GroupReserve
?>
    <div align="center">
        [ <a href="./">Back</a> ]
        <br />
        <span>${obj.model_title}</span>:
        <span>${obj.title}</span><br/>
        <span>${obj.phones_more}</span><br/>
        <a href='edit_req'>Edit</a>
    </div>
<div>${len( customers)}</div>
    <br />
    <table class="maintable">
        
        <thead>
        <tr>
            
            <th>Customer</th>
            <th>Main phone</th>
            <th>Phones</th>
            <th>Personality</th>
        </tr>
        </thead>
        <tbody>
            <tr py:for="c in customers">
                <td>${c.title}</td>
                <td>${c.phone_main}</td>
                <td>${c.phones_more}</td>
                <td>
                     <span py:if="c.personality">${c.personality.title}</span>
                     <br/>
                     <span py:if="c.personality">
                     <a href='/Personality_new/${c.personalityID}/edit_req'>Edit</a>
<!--                     <a href='/Personality_new/${c.personalityID}/delete'>Delete</a>
-->                     </span>
                </td>                
            </tr> 
            
        </tbody>
    </table>
<br/>
    <table class="maintable">
        
        <thead>
        <tr>
            <th>Student</th>
            <th>Agreements</th>
            <th><span>Groups</span><br/><span>2012</span></th>
            <th>Personality</th>
            <th><span>Groups</span><br/><span>2013</span></th>
        </tr>
        </thead>

        <tbody>
            <tr py:for="s in students">
                <?python
                class1 = s.schoolForm -(s.last_agreement.initialPlan.year - s.first_agreement.initialPlan.year)
                ?>
                <td>${s.title}</td>
                <td>${s.first_agreement .plan_title} Form ${class1}
                <br/>
                   <span py:if="s.first_agreement .plan_title!=s.last_agreement .plan_title ">
                    ${s.last_agreement .plan_title} Form ${s.schoolForm}</span>
                </td>
                <td>
                    <div py:for="agr in model.StudentAgreement.selectBy(studentID=s.id)">
                       <span py:if="agr.group">
                            <span py:if="not agr.groupReserve">
                                ${agr.group.title}
                            </span>
                            <a py:if="s.personality and not agr.groupReserve" href='add_agreements?old=${agr.id}'>
                                Transfer
                            </a>
                           <a py:if="s.personality and agr.groupReserve and agr.groupReserve.group.year==2012"
                                href='/EducationAgreement_new/${agr.groupReserve.id}/edit_req'>
                                ${agr.groupReserve.title}
                            </a>
                       
                       <br/>
                       </span>                    
                    </div>
                </td>
                <td>
                     <span py:if="not s.personality">
                     <a href='add_student?student_id=${s.id}'>Add</a>
                     </span>
                     <span py:if="s.personality">${s.personality.title}
                     <br/>
                     <a href='/Student_new/${s.personalityID}/edit_req'>Edit</a>
                        </span>
                </td>
                <td >
                     <span py:if="s.personality">
                        <div py:for="agr in GroupReserve.selectBy(studentID=s.personality.id)">
                             <div py:if="agr.group.year==2013">
                       <a   href='/EducationAgreement_new/${agr.id}/edit_req'>
                        ${agr.title}
                       </a>
                       
                       <br/>
                    </div>
                            
                        </div>
                        
                     </span>
                </td>
            </tr>
        </tbody>
    </table>
</body>
</html>
